<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>加减计算器</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
            background-color: #f4f4f4;
        }

       .calculator {
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            padding: 20px;
            text-align: center;
        }

        input {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ccc;
            border-radius: 3px;
        }

        button {
            background-color: #007BFF;
            color: white;
            border: none;
            padding: 10px 20px;
            margin: 5px;
            border-radius: 3px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        #result {
            margin-top: 15px;
            font-weight: bold;
        }
    </style>
</head>

<body>
    <div class="calculator">
        <input type="number" id="num1" placeholder="第一个数">
        <input type="number" id="num2" placeholder="第二个数">
        <button onclick="add()">加</button>
        <button onclick="subtract()">减</button>
        <div id="result"></div>
    </div>

    <script>function add() {
        var num1 = parseFloat(document.getElementById('num1').value);
        var num2 = parseFloat(document.getElementById('num2').value);
        var result = num1 + num2;
        document.getElementById('result').innerHTML = '结果：' + result;
    }
    
    function subtract() {
        var num1 = parseFloat(document.getElementById('num1').value);
        var num2 = parseFloat(document.getElementById('num2').value);
        var result = num1 - num2;
        document.getElementById('result').innerHTML = '结果：' + result;
    }</script>
</body>

</html>